package com.google.coffeeshop.gui.desktop.orderpayment;

import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import javax.swing.SwingConstants;

import com.google.coffeeshop.gui.desktop.orderpayment.invoiceexport.SeatChoosingForPaymentFrame;

public class OrderPaymentActionsPanel extends JPanel {
	private static final long serialVersionUID = 1L;
	
	private OrderPaymentPanel pnlOrderPayment;
	
	public OrderPaymentActionsPanel() {
		setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
		
		JToolBar pnlActions = new JToolBar();
		add(pnlActions);
		pnlActions.setLayout(new GridLayout(1, 4, 0, 0));
		
		JButton btnPayment = new JButton("Payment");
		btnPayment.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				showSeatChoosingForPaymentFrame();
			}
		});
		btnPayment.setVerticalTextPosition(SwingConstants.BOTTOM);
		btnPayment.setHorizontalTextPosition(SwingConstants.CENTER);
		pnlActions.add(btnPayment);
		btnPayment.setIcon(new ImageIcon(OrderPaymentActionsPanel.class.getResource("/com/google/coffeeshop/gui/desktop/icon/size24/pay-24.png")));
		
		JButton btnTransfer = new JButton("Transfer");
		btnTransfer.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				showSeatTransferingFrame();
			}
		});
		btnTransfer.setVerticalTextPosition(SwingConstants.BOTTOM);
		btnTransfer.setHorizontalTextPosition(SwingConstants.CENTER);
		pnlActions.add(btnTransfer);
		btnTransfer.setIcon(new ImageIcon(OrderPaymentActionsPanel.class.getResource("/com/google/coffeeshop/gui/desktop/icon/size24/transfer-24.png")));
		
		JButton btnStop = new JButton("Stop");
		btnStop.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				showSeatChoosingForStopFrame();
			}
		});
		btnStop.setVerticalTextPosition(SwingConstants.BOTTOM);
		btnStop.setHorizontalTextPosition(SwingConstants.CENTER);
		pnlActions.add(btnStop);
		btnStop.setIcon(new ImageIcon(OrderPaymentActionsPanel.class.getResource("/com/google/coffeeshop/gui/desktop/icon/size24/hammer-24.png")));
	}

	public void showSeatChoosingForStopFrame() {
		SeatChoosingForStopFrame frmSeatChoosing = new SeatChoosingForStopFrame(pnlOrderPayment);
		frmSeatChoosing.setVisible(Boolean.TRUE);
	}
	
	private void showSeatChoosingForPaymentFrame() {
		SeatChoosingForPaymentFrame frmSeatChoosing = new SeatChoosingForPaymentFrame(pnlOrderPayment);
		frmSeatChoosing.setVisible(Boolean.TRUE);
	}
	
	public void setOrderPaymentPanel(OrderPaymentPanel pnlOrderPayment) {
		this.pnlOrderPayment = pnlOrderPayment;
	}
	
	private void showSeatTransferingFrame() {
		SeatTransferingFrame frmSeatTransfering = new SeatTransferingFrame(pnlOrderPayment);
		frmSeatTransfering.setVisible(Boolean.TRUE);
	}
	
}
